package com.joinway.framework.data.jdbc.bean;

import org.apache.commons.lang3.StringUtils;

import com.joinway.framework.bean.BaseBean;

public class SelectClause extends BaseBean {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected String select = "";
	
	protected WhereClause whereClause;
	
	protected String order = "";

//	protected Object[] params;
	
	protected Integer page;
	
	protected Integer rows;
	
	public String getSelect() {
		return select;
	}

	public void setSelect(String select) {
		this.select = select;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	@Override
	public String toString() {
		StringBuilder sql = new StringBuilder();
		
		sql.append(select).append(" ");
		
		if(whereClause != null && StringUtils.isNotBlank(whereClause.getWhere())){
			sql.append(whereClause.getWhere()).append(" ");
		}
		
		if(StringUtils.isNotBlank(order)){
			sql.append(order).append(" ");
		}
		
		return sql.toString();
	}

//	public Object[] getParams() {
//		return params;
//	}
//
//	public void setParams(Object[] params) {
//		this.params = params;
//	}

	public WhereClause getWhereClause() {
		return whereClause;
	}

	public void setWhereClause(WhereClause whereClause) {
		this.whereClause = whereClause;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getRows() {
		return rows;
	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}

}

